home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trading on the Edge
/
Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin
/
pc
/
pc_files
/
mktdata
/
econdata
/
docutils
/
test.cpp
< prev
Wrap
C/C++ Source or Header
|
1992-02-09
|
2KB
|
102 lines
#include <iostream.h> // for cout
#include <ctype.h> // for isdigit()
#include <stdio.h> // for fgets()
#include <alloc.h> // for coreleft()
#include <stdlib.h> // for atof()
#include <conio.h> // for cprintf()
#include "bump.h"
void sub();
void tap();
main()
{
unsigned long core;
core = coreleft();
sub();
printf("Core at begining: %lu \n", core);
printf("Core at end : %lu \n", coreleft());
}
void sub()
{
int i, j;
Vector a(4),at(1,4),b(4),c(4),ct(1,4);
Matrix A(4,4),B(4,4),C(4,4),D(4,1),E(1,1);
A.ReadA("amatrix");
A.Display("Here is the A matrix:");
B = 2.*A;
B.Display("This is 2.*A.");
B = A/2.;
B.Display("and this is A/2.");
for (i = 1; i <= 4; i++){
for(j = 1; j <= 4; j++)
B[i][j] = A[i][j]*A[i][j];
}
B.Display("This is the element-by-element square of A.");
tap();
// Inversion is indicated by ! in front of the matrix.
B = !A; //Invert it
B.Display("and here is B = !A ( A inverse):");
C = A*B;
// This next Display will have column width of 15 and 6 decimal places
C.Display("This is A*!A (should be I):",15,6);
tap();
B = (A + A)*!A;
B.Display("B = (A+A)*!A. Should be 2I");
tap();
C = A*A;
C.Display("A*A:");
C = (A+A)*(A+A);
C.Display("(A+A)*(A+A). Should be 4 times the matrix above.");
tap();
B = ~A;
A.Display("Here is A again.");
B.Display("and this is ~A, A transpose.");
tap();
// Now some tests with vectors
a.ReadA("avector");
at = ~a;
a.Display("This is the a vector:");
at.Display("and this is a'. The difference doesn't show in the display.");
b = 2.*a;
b.Display("This is b = 2.*a");
b = a/2.;
b.Display("and this is a/2.");
D << a;
D.Display("And this is D << a :");
tap();
c = A*a;
c.Display("This is A*a");
ct = ~a*~A;
ct.Display("This is ~a*~A. Should look the same as the above.");
tap();
B = ~A*A;
B.Display("This is ~A*A");
// Tests of the / operator
B = A/A;
B.Display("This is A/A. Should be the same as the above.");
tap();
c = A/a;
ct = a/A;
c.Display("This is A/a:");
ct.Display("This is a/A. Should look like the above.");
tap();
E = a/a;
B = at/at;
E.Display("This is a/a:");
B.Display("This is at/at:");
printf("\nEnd of test.\n");
}
void tap()
{
cerr << "\nTap a key to continue. ESC to exit.";
if(getch() == 27) exit(1);
}